export default defineNuxtRouteMiddleware((to, from) => {
  const env = process.env.NODE_ENV;
  const headers = useRequestHeaders()
  const ipCookie = useCookie('UserSource', {
    maxAge: 7 * 24 * 60 * 60, // 7天的秒数
    path: '/',
    // secure: process.env.NODE_ENV === 'production', // 生产环境下只通过 HTTPS 传输
    sameSite: 'lax'
  })
  
  // 将 IP 写入 cookie
  ipCookie.value = 'ceshi_cookie3131'
 
  if (env === "production") {
    if (to.path.startsWith("/ceshi_demo_show") ) {
      return navigateTo("/");
    }
  }
  if (import.meta.server) {
    // console.log(new Date().getTime());
  }
});
